import i18n from '@/plugins/i18n' // 导入vue-i18n
import solarLunar from 'solarlunar-es';

let day29 = []
let day30 = []
let day31 = []
for (let i = 1; i < 32; i++) {
	day31.push({
		value: i < 10 ? ('0' + i) : i,
		label: i < 10 ? ('0' + i) : i
	})
	if (i < 31) {
		day30.push({
			value: i < 10 ? ('0' + i) : i,
			label: i < 10 ? ('0' + i) : i
		})
	}
	if (i < 30) {
		day29.push({
			value: i < 10 ? ('0' + i) : i,
			label: i < 10 ? ('0' + i) : i
		})
	}
}
let aiDataValue = [{
	value: '%',
	label: i18n.t('album.everyYear'),
	children: [{
		value: '%',
		label: i18n.t('album.everyMonth'),
		children: day31
	}, {
		value: '01',
		label: i18n.t('album.January'),
		children: day31
	}, {
		value: '02',
		label: i18n.t('album.February'),
		children: day29
	}, {
		value: '03',
		label: i18n.t('album.March'),
		children: day31
	}, {
		value: '04',
		label: i18n.t('album.April'),
		children: day30
	}, {
		value: '05',
		label: i18n.t('album.May'),
		children: day31
	}, {
		value: '06',
		label: i18n.t('album.June'),
		children: day30
	}, {
		value: '07',
		label: i18n.t('album.July'),
		children: day31
	}, {
		value: '08',
		label: i18n.t('album.August'),
		children: day31
	}, {
		value: '09',
		label: i18n.t('album.September'),
		children: day30
	}, {
		value: '10',
		label: i18n.t('album.October'),
		children: day31
	}, {
		value: '11',
		label: i18n.t('album.November'),
		children: day30
	}, {
		value: '12',
		label: i18n.t('album.December'),
		children: day31
	}]
}]


// {"searchField":"original_date","searchValue":"LIKE '%-01-01'"}
let holidayList = [
	{//元旦
		searchField: 'original_date',
		searchValue: "LIKE '%-01-01'",
		label: i18n.t('holiday.yuandan')
	},
	{//除夕
		searchField: 'original_date',
		searchValue: "IN ('1981-02-04','1982-01-24','1983-02-12','1984-02-01','1985-02-19','1986-02-08','1987-01-28','1988-02-16','1989-02-05','1990-01-26','1991-02-14','1992-02-03','1993-01-22','1994-02-09','1995-01-30','1996-02-18','1997-02-06','1998-01-27','1999-02-15','2000-02-04','2001-01-23','2002-02-11','2003-01-31','2004-01-21','2005-02-08','2006-01-28','2007-02-17','2008-02-06','2009-01-25','2010-02-13','2011-02-02','2012-01-22','2013-02-09','2014-01-30','2015-02-18','2016-02-07','2017-01-27','2018-02-15','2019-02-04','2020-01-24','2021-02-11','2022-01-31','2023-01-21','2024-02-09','2025-01-28','2026-02-16','2027-02-05','2028-01-25','2029-02-12','2030-02-02','2031-01-22','2032-02-10','2033-01-30','2034-02-18','2035-02-07','2036-01-27','2037-02-14','2038-02-03','2039-01-23','2040-02-11','2041-01-31','2042-01-21','2043-02-09','2044-01-29','2045-02-16','2046-02-05','2047-01-25','2048-02-13','2049-02-01','2050-01-22','2051-02-10','2052-01-31','2053-02-18','2054-02-07','2055-01-27','2056-02-14','2057-02-03','2058-01-23','2059-02-11','2060-02-01','2061-01-20','2062-02-08','2063-01-28','2064-02-16','2065-02-04','2066-01-25','2067-02-13','2068-02-02','2069-01-22','2070-02-10','2071-01-30','2072-02-18','2073-02-06','2074-01-26','2075-02-14','2076-02-04','2077-01-23','2078-02-11','2079-02-01','2080-01-21','2081-02-08','2082-01-28','2083-02-16','2084-02-05','2085-01-25','2086-02-13','2087-02-02','2088-01-23','2089-02-09','2090-01-29','2091-02-17','2092-02-06','2093-01-26','2094-02-14','2095-02-04','2096-01-24','2097-02-11','2098-01-31','2099-01-20','2100-02-08')",
		label: i18n.t('holiday.chuxi')
	},
	{//初一
		searchField: 'original_date',
		searchValue: "IN ('1980-02-16','1981-02-05','1982-01-25','1983-02-13','1984-02-02','1985-02-20','1986-02-09','1987-01-29','1988-02-17','1989-02-06','1990-01-27','1991-02-15','1992-02-04','1993-01-23','1994-02-10','1995-01-31','1996-02-19','1997-02-07','1998-01-28','1999-02-16','2000-02-05','2001-01-24','2002-02-12','2003-02-01','2004-01-22','2005-02-09','2006-01-29','2007-02-18','2008-02-07','2009-01-26','2010-02-14','2011-02-03','2012-01-23','2013-02-10','2014-01-31','2015-02-19','2016-02-08','2017-01-28','2018-02-16','2019-02-05','2020-01-25','2021-02-12','2022-02-01','2023-01-22','2024-02-10','2025-01-29','2026-02-17','2027-02-06','2028-01-26','2029-02-13','2030-02-03','2031-01-23','2032-02-11','2033-01-31','2034-02-19','2035-02-08','2036-01-28','2037-02-15','2038-02-04','2039-01-24','2040-02-12','2041-02-01','2042-01-22','2043-02-10','2044-01-30','2045-02-17','2046-02-06','2047-01-26','2048-02-14','2049-02-02','2050-01-23','2051-02-11','2052-02-01','2053-02-19','2054-02-08','2055-01-28','2056-02-15','2057-02-04','2058-01-24','2059-02-12','2060-02-02','2061-01-21','2062-02-09','2063-01-29','2064-02-17','2065-02-05','2066-01-26','2067-02-14','2068-02-03','2069-01-23','2070-02-11','2071-01-31','2072-02-19','2073-02-07','2074-01-27','2075-02-15','2076-02-05','2077-01-24','2078-02-12','2079-02-02','2080-01-22','2081-02-09','2082-01-29','2083-02-17','2084-02-06','2085-01-26','2086-02-14','2087-02-03','2088-01-24','2089-02-10','2090-01-30','2091-02-18','2092-02-07','2093-01-27','2094-02-15','2095-02-05','2096-01-25','2097-02-12','2098-02-01','2099-01-21')",
		label: i18n.t('holiday.chuyi')
	},
	{//元宵节
		searchField: 'original_date',
		searchValue: "IN ('1980-03-01','1981-02-19','1982-02-08','1983-02-27','1984-02-16','1985-03-06','1986-02-23','1987-02-12','1988-03-02','1989-02-20','1990-02-10','1991-03-01','1992-02-18','1993-02-06','1994-02-24','1995-02-14','1996-03-04','1997-02-21','1998-02-11','1999-03-02','2000-02-19','2001-02-07','2002-02-26','2003-02-15','2004-02-05','2005-02-23','2006-02-12','2007-03-04','2008-02-21','2009-02-09','2010-02-28','2011-02-17','2012-02-06','2013-02-24','2014-02-14','2015-03-05','2016-02-22','2017-02-11','2018-03-02','2019-02-19','2020-02-08','2021-02-26','2022-02-15','2023-02-05','2024-02-24','2025-02-12','2026-03-03','2027-02-20','2028-02-09','2029-02-27','2030-02-17','2031-02-06','2032-02-25','2033-02-14','2034-03-05','2035-02-22','2036-02-11','2037-03-01','2038-02-18','2039-02-07','2040-02-26','2041-02-15','2042-02-05','2043-02-24','2044-02-13','2045-03-03','2046-02-20','2047-02-09','2048-02-28','2049-02-16','2050-02-06','2051-02-25','2052-02-15','2053-03-05','2054-02-22','2055-02-11','2056-02-29','2057-02-18','2058-02-07','2059-02-26','2060-02-16','2061-02-04','2062-02-23','2063-02-12','2064-03-02','2065-02-19','2066-02-09','2067-02-28','2068-02-17','2069-02-06','2070-02-25','2071-02-14','2072-03-04','2073-02-21','2074-02-10','2075-03-01','2076-02-19','2077-02-07','2078-02-26','2079-02-16','2080-02-05','2081-02-23','2082-02-12','2083-03-03','2084-02-20','2085-02-09','2086-02-28','2087-02-17','2088-02-07','2089-02-24','2090-02-13','2091-03-04','2092-02-21','2093-02-10','2094-03-01','2095-02-19','2096-02-08','2097-02-26','2098-02-15','2099-02-04')",
		label: i18n.t('holiday.yuanxiaojie')
	},
	{//情人节
		searchField: 'original_date',
		searchValue: "LIKE '%-02-14'",
		label: i18n.t('holiday.qingrenjie')
	},
	{//妇女节
		searchField: 'original_date',
		searchValue: "LIKE '%-03-08'",
		label: i18n.t('holiday.funvjie')
	},
	{//愚人节
		searchField: 'original_date',
		searchValue: "LIKE '%-04-01'",
		label: i18n.t('holiday.yurenjie')
	},
	{//劳动节
		searchField: 'original_date',
		searchValue: "LIKE '%-05-01'",
		label: i18n.t('holiday.laodongjie')
	},
	{//儿童节
		searchField: 'original_date',
		searchValue: "LIKE '%-06-01'",
		label: i18n.t('holiday.ertongjie')
	},
	{//七夕
		searchField: 'original_date',
		searchValue: "IN ('1980-08-17','1981-08-06','1982-08-25','1983-08-15','1984-08-03','1985-08-22','1986-08-12','1987-08-30','1988-08-18','1989-08-08','1990-08-26','1991-08-16','1992-08-05','1993-08-24','1994-08-13','1995-08-02','1996-08-20','1997-08-09','1998-08-28','1999-08-17','2000-08-06','2001-08-25','2002-08-15','2003-08-04','2004-08-22','2005-08-11','2006-07-31','2007-08-19','2008-08-07','2009-08-26','2010-08-16','2011-08-06','2012-08-23','2013-08-13','2014-08-02','2015-08-20','2016-08-09','2017-08-28','2018-08-17','2019-08-07','2020-08-25','2021-08-14','2022-08-04','2023-08-22','2024-08-10','2025-08-29','2026-08-19','2027-08-08','2028-08-26','2029-08-16','2030-08-05','2031-08-24','2032-08-12','2033-08-01','2034-08-20','2035-08-10','2036-08-28','2037-08-17','2038-08-07','2039-08-26','2040-08-14','2041-08-03','2042-08-22','2043-08-11','2044-07-31','2045-08-19','2046-08-08','2047-08-27','2048-08-16','2049-08-05','2050-08-23','2051-08-12','2052-08-01','2053-08-20','2054-08-10','2055-08-29','2056-08-17','2057-08-06','2058-08-25','2059-08-14','2060-08-02','2061-08-21','2062-08-11','2063-08-01','2064-08-19','2065-08-08','2066-08-27','2067-08-16','2068-08-04','2069-08-23','2070-08-12','2071-08-02','2072-08-20','2073-08-10','2074-08-28','2075-08-18','2076-08-06','2077-08-24','2078-08-14','2079-08-03','2080-08-21','2081-08-11','2082-07-31','2083-08-19','2084-08-08','2085-08-26','2086-08-15','2087-08-05','2088-08-23','2089-08-12','2090-08-02','2091-08-21','2092-08-09','2093-08-28','2094-08-17','2095-08-06','2096-08-24','2097-08-14','2098-08-03','2099-08-22')",
		label: i18n.t('holiday.qixi')
	},
	{//端午节
		searchField: 'original_date',
		searchValue: "IN ('1980-06-17','1981-06-06','1982-06-25','1983-06-15','1984-06-04','1985-06-22','1986-06-11','1987-05-31','1988-06-18','1989-06-08','1990-05-28','1991-06-16','1992-06-05','1993-06-24','1994-06-13','1995-06-02','1996-06-20','1997-06-09','1998-05-30','1999-06-18','2000-06-06','2001-06-25','2002-06-15','2003-06-04','2004-06-22','2005-06-11','2006-05-31','2007-06-19','2008-06-08','2009-05-28','2010-06-16','2011-06-06','2012-06-23','2013-06-12','2014-06-02','2015-06-20','2016-06-09','2017-05-30','2018-06-18','2019-06-07','2020-06-25','2021-06-14','2022-06-03','2023-06-22','2024-06-10','2025-05-31','2026-06-19','2027-06-09','2028-05-28','2029-06-16','2030-06-05','2031-06-24','2032-06-12','2033-06-01','2034-06-20','2035-06-10','2036-05-30','2037-06-18','2038-06-07','2039-05-27','2040-06-14','2041-06-03','2042-06-22','2043-06-11','2044-05-31','2045-06-19','2046-06-08','2047-05-29','2048-06-15','2049-06-04','2050-06-23','2051-06-13','2052-06-01','2053-06-20','2054-06-10','2055-05-30','2056-06-17','2057-06-06','2058-06-25','2059-06-14','2060-06-03','2061-06-22','2062-06-11','2063-06-01','2064-06-19','2065-06-08','2066-05-28','2067-06-16','2068-06-04','2069-06-23','2070-06-13','2071-06-02','2072-06-20','2073-06-10','2074-05-30','2075-06-17','2076-06-06','2077-06-24','2078-06-14','2079-06-04','2080-06-22','2081-06-11','2082-06-01','2083-06-19','2084-06-07','2085-05-27','2086-06-15','2087-06-05','2088-06-23','2089-06-13','2090-06-02','2091-06-21','2092-06-09','2093-05-29','2094-06-17','2095-06-06','2096-06-24','2097-06-14','2098-06-04','2099-06-23')",
		label: i18n.t('holiday.duanwujie')
	},
	{//教师节
		searchField: 'original_date',
		searchValue: "LIKE '%-09-10'",
		label: i18n.t('holiday.jiaoshijie')
	},
	{//中秋节
		searchField: 'original_date',
		searchValue: "IN ('1980-09-23','1981-09-12','1982-10-01','1983-09-21','1984-09-10','1985-09-29','1986-09-18','1987-10-07','1988-09-25','1989-09-14','1990-10-03','1991-09-22','1992-09-11','1993-09-30','1994-09-20','1995-09-09','1996-09-27','1997-09-16','1998-10-05','1999-09-24','2000-09-12','2001-10-01','2002-09-21','2003-09-11','2004-09-28','2005-09-18','2006-10-06','2007-09-25','2008-09-14','2009-10-03','2010-09-22','2011-09-12','2012-09-30','2013-09-19','2014-09-08','2015-09-27','2016-09-15','2017-10-04','2018-09-24','2019-09-13','2020-10-01','2021-09-21','2022-09-10','2023-09-29','2024-09-17','2025-10-06','2026-09-25','2027-09-15','2028-10-03','2029-09-22','2030-09-12','2031-10-01','2032-09-19','2033-09-08','2034-09-27','2035-09-16','2036-10-04','2037-09-24','2038-09-13','2039-10-02','2040-09-20','2041-09-10','2042-09-28','2043-09-17','2044-10-05','2045-09-25','2046-09-15','2047-10-04','2048-09-22','2049-09-11','2050-09-30','2051-09-19','2052-09-07','2053-09-26','2054-09-16','2055-10-05','2056-09-24','2057-09-13','2058-10-02','2059-09-21','2060-09-09','2061-09-28','2062-09-17','2063-10-06','2064-09-25','2065-09-15','2066-10-03','2067-09-23','2068-09-11','2069-09-29','2070-09-19','2071-09-08','2072-09-26','2073-09-16','2074-10-05','2075-09-24','2076-09-12','2077-10-01','2078-09-20','2079-09-10','2080-09-28','2081-09-17','2082-10-06','2083-09-26','2084-09-14','2085-10-03','2086-09-22','2087-09-11','2088-09-29','2089-09-18','2090-09-08','2091-09-27','2092-09-16','2093-10-05','2094-09-24','2095-09-13','2096-09-30','2097-09-20','2098-09-09','2099-09-29')",
		label: i18n.t('holiday.zhongqiujie')
	},
	{//国庆节
		searchField: 'original_date',
		searchValue: "LIKE '%-10-01'",
		label: i18n.t('holiday.guoqingjie')
	},
	{//重阳节
		searchField: 'original_date',
		searchValue: "IN ('1980-10-17','1981-10-06','1982-10-25','1983-10-14','1984-10-03','1985-10-22','1986-10-12','1987-10-31','1988-10-19','1989-10-08','1990-10-26','1991-10-16','1992-10-04','1993-10-23','1994-10-13','1995-11-01','1996-10-20','1997-10-10','1998-10-28','1999-10-17','2000-10-06','2001-10-25','2002-10-14','2003-10-04','2004-10-22','2005-10-11','2006-10-30','2007-10-19','2008-10-07','2009-10-26','2010-10-16','2011-10-05','2012-10-23','2013-10-13','2014-10-02','2015-10-21','2016-10-09','2017-10-28','2018-10-17','2019-10-07','2020-10-25','2021-10-14','2022-10-04','2023-10-23','2024-10-11','2025-10-29','2026-10-18','2027-10-08','2028-10-26','2029-10-16','2030-10-05','2031-10-24','2032-10-12','2033-10-01','2034-10-20','2035-10-09','2036-10-27','2037-10-17','2038-10-07','2039-10-26','2040-10-14','2041-10-03','2042-10-22','2043-10-11','2044-10-29','2045-10-18','2046-10-08','2047-10-27','2048-10-16','2049-10-05','2050-10-24','2051-10-13','2052-10-30','2053-10-20','2054-10-09','2055-10-28','2056-10-17','2057-10-07','2058-10-25','2059-10-14','2060-10-02','2061-10-21','2062-10-11','2063-10-30','2064-10-18','2065-10-08','2066-10-27','2067-10-16','2068-10-04','2069-10-23','2070-10-12','2071-10-31','2072-10-20','2073-10-09','2074-10-28','2075-10-18','2076-10-06','2077-10-25','2078-10-14','2079-10-03','2080-10-21','2081-10-11','2082-10-30','2083-10-19','2084-10-08','2085-10-27','2086-10-16','2087-10-05','2088-10-22','2089-10-12','2090-10-31','2091-10-21','2092-10-09','2093-10-28','2094-10-17','2095-10-06','2096-10-24','2097-10-13','2098-10-03','2099-10-22')",
		label: i18n.t('holiday.chongyangjie')
	},
	{//万圣节
		searchField: 'original_date',
		searchValue: "LIKE '%-11-01'",
		label: i18n.t('holiday.wanshengjie')
	},
	{//平安夜
		searchField: 'original_date',
		searchValue: "LIKE '%-12-24'",
		label: i18n.t('holiday.pinganye')
	},
	{//圣诞节
		searchField: 'original_date',
		searchValue: "LIKE '%-12-25'",
		label: i18n.t('holiday.shengdanjie')
	}
]
//阴历智能日期 范围 1980-2100
function getLunarInSql(month,day){
	day=parseInt(day)
	if(month!="%"){
		month=parseInt(month)
	}
	let useDateList=[]
	try{
		function addLunarDateToList(lunarData){
			if(!lunarData||!lunarData.cYear||!lunarData.cMonth||!lunarData.cDay){
				return
			}
			let monthValue=lunarData.cMonth
			if(monthValue<10){
				monthValue="0"+monthValue
			}
			let dayValue=lunarData.cDay
			if(dayValue<10){
				dayValue="0"+dayValue
			}
			useDateList.push(`${lunarData.cYear}-${monthValue}-${dayValue}`)
		}
		for(let i=1980;i<2100;i++){
			let year=i 
			if(month=="%"){
				for(let j=1;j<13;j++){
					console.log(year,j,day)
					addLunarDateToList(solarLunar.lunar2solar(year, j, day))
				}
			}else{
				addLunarDateToList(solarLunar.lunar2solar(year, month, day))
			}
		}
		let sql=" IN ("
		for(let i in useDateList){
			sql+=`'${useDateList[i]}'`
			if(i!=useDateList.length-1){
				sql+=","
			}
		}
		sql+=")"
		return sql
	}catch(err){
		return  ""
	}
	
}
export default {
	aiDataValue: aiDataValue,
	holidayList:holidayList,
	getLunarInSql:getLunarInSql
}
